local skill = fk.CreateSkill{
  name = "action__hongyundangtou_ol_skill",
}

local HX = require "packages/huixiangkill/hxfs"

Fk:loadTranslationTable{
  ["action__hongyundangtou_ol"] = "红运当头",
  ["action__hongyundangtou_ol_skill"] = "红运当头",
  [":action__hongyundangtou_ol"] = "锦囊牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：你和一名有手牌的其他角色 <br /><b>效果</b>：令你与其各弃置至多两张牌，从牌堆或弃牌堆中获得等量红桃牌。",
  ["#action__hongyundangtou_ol_skill"] = "选择你和一名有手牌的其他角色，令你与其各弃置至多两张牌，从牌堆或弃牌堆中获得等量红桃牌",
}


skill:addEffect("cardskill", {
  mute = true,
  name = "action__hongyundangtou_ol",
  prompt = "#action__hongyundangtou_ol_skill",
  target_num = 2,
  mod_target_filter = function(self, player, to_select, selected, card, extra_data)
    if #selected == 0 then
      return to_select == player
    elseif #selected == 1 then
      return to_select ~= player
    end
  end,
  target_filter = function(self, player, to_select, selected, _, card, extra_data)
    if #selected >= 2 then
      return false
    elseif #selected == 0 then
      return Util.CardTargetFilter(self, player, to_select, selected, _, card, extra_data)
    else
      return to_select ~= player
    end
  end,
  on_effect = function(self, room, effect)
    local x = room:askToDiscard(effect.to, {
      min_num = 1,
      max_num = 2,
      prompt = "你可以弃置至多两张牌，从牌堆或弃牌堆中获得等量红桃牌",
      skill_name = skill.name,
      cancelable = true,
      include_equip = true,
    })
    if #x > 0 then
      local cards = room:getCardsFromPileByRule(".|.|heart", #x, "allPiles")
      room:obtainCard(effect.to, cards, false, fk.ReasonPrey, nil, skill.name)
    end
  end,
})


return skill